/**
 * Copyright 2009 - Morten Udnæs
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.javabatch.fileio;

import java.util.List;

/**
 * File based store which supports basic operations.
 *
 * @author eco
 *
 */
public interface FileStore {

    /** Open files for access. */
    void open();

    /** Closes file after fileaccess. */
    void close();

    /**
     * Get the first record of the file.
     */
    FileBuffer getFirst();

    /**
     * Get next record based on current position.
     */
    FileBuffer readNext();

    /**
     * Get multiple record in one call.
     *
     * @param batchSize
     *            number of records to fetch in one call
     */
    List<FileBuffer> getBatch(int batchSize);

    /**
     * Find records based on field values.
     *
     * @param field
     *            field to use search for value
     * @param value
     *            value to search for
     */
    FileBuffer find(final Field field, final byte[] value);

    void write(final FileBuffer record);
    
    boolean hasMore();

}
